import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const siteRoot = '/forum'

const routes = [
    {
        path: siteRoot + '/home',
        name: 'home',
        component: () => import('../views/Home'),
        // redirect: ()=>({ name: 'environment' }),
        // children: [
        //     {
        //         path: 'environment',
        //         name: 'environment',
        //         component: () => import('@/views/Environment')
        //     },
        //     {
        //         path: 'notice',
        //         name: 'notice',
        //         component: () => import('@/views/Notice')
        //     }
        // ]
    },
    {
        path: siteRoot + '/article/:articleCategory',
        name: 'category',
        component: () => import('../views/Category'),
    },
    {
        path: siteRoot + '/categoryTemplate',
        name: 'category',
        component: () => import('../views/Category'),
    },
    {
        path: siteRoot + '/article/:articleCategory/:articleName',
        name: 'article',
        props: true, // 设置props属性为true, 则可以在CategoryTemplate页面中直接取参数
        component: () => import('../views/Article'),
    },
    {
        path: siteRoot + '/articleTemplate',
        name: 'article',
        props: true, // 设置props属性为true, 则可以在CategoryTemplate页面中直接取参数
        component: () => import('../views/Article'),
    },
    {
        path: siteRoot + '/registerLog',
        name: 'registerLog',
        component: () => import('../views/RegisterLog')
    },
    {
        path: '*',
        component: () => import('../../../views/NotFound')
    }
]

const RouterConfig = {
    // 使用HTML5的历史路由模式
    mode: 'history',
    routes
}

const router = new VueRouter(RouterConfig);

export default router;
